<?php
/**
 * Created by PhpStorm.
 * User: lawrence
 * Date: 01.06.2014
 * Time: 14:19
 */

class Contact_Request extends  CI_Controller
{
    public function get_data()
    {
        $data['message'] = $this->input->post('message');
        $identity = $this->input->post('identity');

        $data['window'] = 'contact';
        $data['pagetitle'] = 'Contact Us';
        $this->load->view('header', $data);

        $this->load->library('session');

        if($data['message'] != '')
        {
            if($identity == 'anonym')
            {
                $this->Db_Model_Contact->insert_message($this->input->post('message'), 0);
            }
            else
            {
                if($this->session->userdata('logged') == 1)
                {
                    $this->Db_Model_Contact->insert_message($this->input->post('message'), $this->session->userdata('id'));
                }
                else
                {
                    $this->Db_Model_Contact->insert_message($this->input->post('message'), 0);
                }
            }

            $this->load->view('contact_submitted', $data);
        }
        else
        {
            $this->load->view('empty_message');
        }

        $this->load->view('footer');
    }
} 